package com.wulijie.iterator;

import java.util.Iterator;

/**
 * @Author cui
 * @Data
 */
public class ComputerIterator implements Iterator {

    private Department[] departments;
    private int position;

    public ComputerIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        return position < departments.length && null != departments[position];
    }

    @Override
    public Object next() {
        Department department = departments[position];
        position += 1;
        return department;
    }
}
